package com.yuanheng100.ems4j.mapper;

import com.yuanheng100.ems4j.model.Ems4jSMS;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface Ems4jSMSMapper
{

    @Insert({
            "INSERT INTO ems4j_sms (smsId, content, ",
            "receiver, fromName, ",
            "toName, fromDate, ",
            "result)",
            "VALUES (#{smsId,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, ",
            "#{receiver,jdbcType=BIGINT}, #{fromName,jdbcType=VARCHAR}, ",
            "#{toName,jdbcType=VARCHAR}, #{fromDate,jdbcType=TIMESTAMP}, ",
            "#{result,jdbcType=SMALLINT})"
    })
    int insert(Ems4jSMS record);

    @InsertProvider(type = Ems4jSMSSqlProvider.class, method = "insertSelective")
    int insertSelective(Ems4jSMS record);

    @Select({
            "SELECT",
            "smsId, content, receiver, fromName, toName, fromDate, result",
            "FROM ems4j_sms",
            "WHERE smsId = #{smsId,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "smsId", property = "smsId", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "content", property = "content", jdbcType = JdbcType.VARCHAR),
            @Result(column = "receiver", property = "receiver", jdbcType = JdbcType.BIGINT),
            @Result(column = "fromName", property = "fromName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "toName", property = "toName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fromDate", property = "fromDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "result", property = "result", jdbcType = JdbcType.SMALLINT)
    })
    Ems4jSMS selectByPrimaryKey(Integer smsId);

    @UpdateProvider(type = Ems4jSMSSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Ems4jSMS record);

    @Update({
            "UPDATE ems4j_sms",
            "SET content = #{content,jdbcType=VARCHAR},",
            "receiver = #{receiver,jdbcType=BIGINT},",
            "fromName = #{fromName,jdbcType=VARCHAR},",
            "toName = #{toName,jdbcType=VARCHAR},",
            "fromDate = #{fromDate,jdbcType=TIMESTAMP},",
            "result = #{result,jdbcType=SMALLINT}",
            "WHERE smsId = #{smsId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Ems4jSMS record);
}